package com.cn.wanxi.model;

public class ResultModel {
    private Integer code;
    private String msg;
    private Integer count;
    private Object data;

    private static ResultModel getResultModel(int count, String msg, int code, Object data) {
        ResultModel resultModel = new ResultModel();
        resultModel.setCount(count);
        resultModel.setMsg(msg);
        resultModel.setCode(code);
        resultModel.setData(data);
        return resultModel;
    }

    /**
     * 只有数据
     *
     * @param data
     * @return
     */
    public static ResultModel getResultModel(Object data) {
//        ResultModel resultModel = new ResultModel();
//        resultModel.setCount(0);
//        resultModel.setMsg("");
//        resultModel.setCode(0);
//        resultModel.setData(data);
//        return resultModel;
        return getResultModel(0, "", 0, data);
    }

    /**
     * 影响条数和数据
     *
     * @param count
     * @param data
     * @return
     */
    public static ResultModel getResultModel(int count, Object data) {
//        ResultModel resultModel = new ResultModel();
//        resultModel.setCount(count);
//        resultModel.setMsg("");
//        resultModel.setCode(0);
//        resultModel.setData(data);
//        return resultModel;
        return getResultModel(count, "", 0, data);
    }

    /**
     * 影响的条数,新增，修改，删除,得到总条数
     *
     * @param count
     * @return
     */
    public static ResultModel getResultModel(int count) {
//        ResultModel resultModel = new ResultModel();
//        resultModel.setCount(count);
//        resultModel.setMsg("");
//        resultModel.setCode(0);
//        resultModel.setData(null);
//        return resultModel;
        return getResultModel(count, "", 0, null);
    }

    /**
     * 只传消息
     *
     * @param msg
     * @return
     */
    public static ResultModel getResultModel(String msg) {

        return getResultModel(0, msg, 0, null);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
